package com.glory.brepda.adapter;

import android.widget.CheckBox;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.brepda.R;
import com.glory.brepda.entity.PackageEntity;
import com.glory.brepda.entity.SimpleEntity;

import java.util.ArrayList;
import java.util.List;

public class PackageBinListAdapter extends BaseQuickAdapter<PackageEntity.SuggestShelfEntity, BaseViewHolder> {

    private List<PackageEntity.SuggestShelfEntity> mList;


    public PackageBinListAdapter(@Nullable List<PackageEntity.SuggestShelfEntity> data) {
        super(R.layout.adapter_ft_bin,data);
        mList = new ArrayList<>();
    }

    @Override
    protected void convert(BaseViewHolder helper, PackageEntity.SuggestShelfEntity item) {
        helper.setText(R.id.tvName,item.getPackLotId())
                .setText(R.id.tvDesc,item.getPackMainQty())
                .setGone(R.id.tvQTY,false);

        CheckBox checkBox = helper.getView(R.id.checkbox);
        checkBox.setChecked(false);
        checkBox.setOnClickListener(view -> {
            if (checkBox.isChecked()){
                mList.add(item);
            }else {
                mList.remove(item);
            }
        });
    }

    public List<PackageEntity.SuggestShelfEntity> getSelectorData(){
        return mList;
    }
}
